<template>
	<view style="padding: 20rpx;">
		<!-- 顶部 -->
		<view class="top">
			<view class="title">自助服务</view>
			<view class="questions-list">
				<view class="questions-item" v-for="(item, index) in questions" :key="index"
					@click="toPage(index, item)">
					<view class="item-img">
						<image :src="item.img" mode=""></image>
					</view>
					<view class="item-title">{{ item.title }}</view>
				</view>
			</view>
		</view>
		<!-- 中间 -->
		<view class="middle">
			<view class="title">猜您想问</view>
			<view class="type-list">
				<view class="type-item" v-for="(item, index) in types" :key="index" @click="toHelpcenter(item)">
					<view class="type-title">{{ index + 1 }}.&nbsp;&nbsp;{{ item.article_title }}</view>
					<view class="right">
						<image src="@/static/images/more.png" mode="widthFix" style="width: 12rpx;"></image>
					</view>
				</view>
			</view>
		</view>
		<call-phone></call-phone>
	</view>
</template>

<script>
	import callPhone from "@/components/service/callPhone.vue";
	export default {
		components: {
			callPhone,
		},
		data() {
			return {
				type: '',
				types: [],
				questions: [{
					title: '租金问题',
					id: 10,
					img: '../../static/service/service-05.png'
				}, {
					title: '售后问题',
					id: 18,
					img: '../../static/service/service-03.png'
				}, {
					title: '押金问题',
					id: 16,
					img: '../../static/service/service-06.png'
				}, {
					title: '其他问题',
					id: 10,
					img: '../../static/service/service-02.png'
				}, {
					title: '投诉问题',
					img: '../../static/service/service-04.png'
				}]
			}
		},
		onLoad() {
			this.getList()
			this.type = ""
		},
		onShow() {
			this.type = ""
		},
		methods: {
			// 打开对应页
			toPage(index, i) {
				if (index === 4) {
					uni.navigateTo({
						url: '/pagesB/complaint/complaint'
					})
				} else {
					uni.navigateTo({
						url: `/pagesB/service/rent?type=${ i.id }&name=${ i.title }`
					})
				}
			},
			// 打开咨询详情
			toHelpcenter(i) {
				uni.navigateTo({
					url: `/pagesB/service/helpcenter/helpcenter?type=${ JSON.stringify(i) }`
				})
			},
			// 获取问题
			getList() {
				uni.$http.get(`/Wechat/Help/getCommonProblemType?type=${ this.type }`).then(res => {
					this.types = res.data.data
				})
			}
		},
	}
</script>

<style scoped>
	.top,
	.middle {
		padding: 20rpx;
		background-color: #fff;
		border-radius: 20rpx;
	}
	.btnService{
		display: flex;
		justify-content: space-between;
		
	}
	.middle {
		margin-top: 20rpx;
	}

	.type-title {
		font-size: 28rpx;
	}

	.title {
		padding: 10rpx 20rpx;
		font-weight: 600;
		position: relative;
		border-bottom: 0.2rpx solid #d6d6d6;
	}

	.title:after {
		position: absolute;
		content: "";
		width: 5rpx;
		height: 50%;
		background-color: #ff0000;
		left: 0;
		top: 25%;
	}

	.type-item {
		border-bottom: 0.5rpx solid #eaeaea;
		display: flex;
		justify-content: space-between;
		padding: 20rpx 0;
		color: #999;
	}

	/* .type-item:last-of-type {
		border-bottom: 0;
	} */

	.questions-list {
		display: flex;
		flex-wrap: nowrap;
		margin-top: 10rpx;
	}

	.questions-item {
		width: 20%;
		box-sizing: border-box;
		padding: 5rpx;
		text-align: center;
		font-size: 25rpx;
	}

	.questions-item .item-title {
		margin-top: -15rpx;
	}

	image {
		width: 130rpx;
		height: 130rpx;
	}

	.divider {
		width: 100%;
		height: 0.5px;
		background-color: #999;
	}
</style>